<!DOCTYPE html>
<div lang="en">
<head>
    <meta charset="UTF-8">
    <title>芯佑电商_确认信息</title>
    <#include "/website/commonWebsite.html">
    <!--==选择框==-->
    <link href="/website/js/checkbox/checkbox.css" rel="stylesheet" type="text/css" />
    <script src="/website/js/checkbox/checkbox.js"></script>
    <!--==弹出框==-->
    <script src="/website/js/popup/popup.js"></script>
    <link rel="stylesheet" href="/website/js/popup/common.css" type="text/css"/>
    <link rel="stylesheet" href="/website/js/popup/popup.css" type="text/css"/><!-- 数字转货币-->
    <script src="/website/js/accounting.js-master/accounting.js"></script>
</head>


<body>

<!--==头部==-->
<div class="header">
    <#include "/website/header.html">
</div>

<!--==内容区域==-->
<div class="home_n">
    <input type="hidden" id="pks" value="${pks}">
    <div  class="home_nr">
        <!--==地址==-->
        <div class="shoinf-add">
            <!--标题-->
            <div class="shoinf-add-bt">选择地址</div>
            <!--地址-->
            <#if addressList?? && addressList?size &gt;0>
                <#list addressList as item>
                    <div class="shoinf-add-nr">
                        <input type="hidden" id="addressPk" value="${item.pk}">
                        <div class="shoinf-rad">
                            <label><input type="radio" name="m" onclick="choseOne(this);"><span></span></label>
                        </div>
                        <div class="shoinf-add-nrd">
                            <h1><strong>${item.receiver_name}</strong>${item.receiver_phone}</h1>
                            <p>${item.receiver_province}${item.receiver_city}${item.receiver_county}${item.receiver_address}</p>
                        </div>
                        <div class="shoinf-add-nra box">
                            <a href="javascript:;" class="bounceIn" onclick="updateAddress(this)">修改</a>
                        </div>
                    </div>
                </#list>
            </#if>
            <!--按钮-->
            <div class="shoinf-add-an box">
                <a href="javascript:;" class="bounceIn">添加新地址</a>
            </div>
        </div>
        <!--==订单产品==-->
        <div class="shoinf-add">
            <!--标题-->
            <div class="shoinf-add-bt border-no">订单产品</div>
                <#if shoppingCartList?? && shoppingCartList?size &gt;0>
                    <#list shoppingCartList as item>
                        <div class="sholis-lis borderx">
                            <div class="sholis-lis-c">
                                <#assign imgPaths=item.product_avatar?split(";")>
                                <h1><a href="/website/productDetails?productPk=${item.no1}"><img src="//${imgPaths[0]}" width="275" height="275"></a></h1>
                                <dl>
                                    <dt><a href="#">${item.product_name}</a></dt>
                                    <dd>${item.sku_name}</dd>
                                </dl>
                            </div>
                            <div class="sholis-lis-r paddingk">
                                <p>单价</p>
                                <p><strong class="price">¥${item.sku_off_price}</strong></p>
                                <p>${item.product_sku_count}</p>
                            </div>
                            <div class="sholis-lis-r paddingk">
                                <p>总金额</p>
                                <p><strong class="red totalPrice">¥${item.total_price}</strong></p>
                                <p>(含运费：￥0.00)</p>
                            </div>
                        </div>
                    </#list>
                </#if>
            <div class="shoinf-addt-nra">
                <h1>备注：</h1>
                <p><input type="text" placeholder="请填写备注信息" name="c11" id="c11" value=""></p>
            </div>
            </div>
        <!--==发票信息==-->
        <div class="shoinf-add">
            <!--标题-->
            <div class="shoinf-add-bt">
                <a href="javascript:void(0)" onclick="showBillNo()">不开票</a>
                &nbsp;&nbsp;&nbsp;
                <a href="javascript:void(0)" onclick="showBill()">开票>></a>
            </div>
            <!--发票信息-->
            <div class="shoinf-add-nr bill" style="height: 50px;">
                <div class="shoinf-addt billMessage" style="display: none;">
                    <div class="shoinf-addt-bt">
                        发票详情
                    </div>
                    <form id="billMessage">
                        <div class="shoinf-addt-nr">
                            <div class="shoinf-addt-nra">
                                <h1>发票抬头：</h1>
                                <p><input type="text" placeholder="请填写公司名称（如是个人发票就直接填写个人）" name="companyName" id="companyName" value=""></p>
                            </div>
                            <div class="shoinf-addt-nra">
                                <h1>税号：</h1>
                                <p><input type="text" placeholder="纳税人识别号" name="taxNumber" id="taxNumber" value=""></p>
                            </div>
                            <h4 style="margin-left: 10px;color: #FF00FF">注：若是普通发票，以下信息不用填写</h4>
                            <br>
                            <div class="shoinf-addt-nra">
                                <h1>公司地址：</h1>
                                <p><input type="text" placeholder="请填写地址" name="receiverName" id="companyAddress" value=""></p>
                            </div>
                            <div class="shoinf-addt-nra">
                                <h1>公司电话：</h1>
                                <p><input type="text" placeholder="请填写完成电话号码" name="receiverPhone" id="companyPhone" value=""></p>
                            </div>
                            <div class="shoinf-addt-nra">
                                <h1>开户行名称：</h1>
                                <p><input type="text" placeholder="请填开户行名称" name="receiverPhone" id="bankName" value=""></p>
                            </div>
                            <div class="shoinf-addt-nra">
                                <h1>开户行账号：</h1>
                                <p><input type="text" placeholder="请填开户行账号" name="receiverPhone" id="bankNumber" value=""></p>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
        <!--==提交==-->
        <div class="shoinf-tj">
            <div class="shoinf-tj-w">总金额：<strong>${allProductPrice}</strong></div>
            <div class="shoinf-tj-a"><button type="button" onclick="toPay()">立即付款</button></div>
        </div>
    </div>
</div>
</div>
</body>
<!--==版权==-->
<script type="text/javascript">
    function load_home() {
        document.getElementById("viewDiv").innerHTML = '';
    }
</script>
<object type="text/html" data="/website/copyright" width="100%" height="370px" style="margin-bottom: -5px;"></object>

<!--==弹出背景==-->
<div id="dialogBg" class="claseDialogBtn"></div>

<!--==弹出内容==-->
<div id="dialog" class="animated">
    <!--内容区域可以替换-->
    <div class="shoinf-addt">
        <div class="shoinf-addt-bt">添加新地址</div>
        <form id="addressMessage">
            <input type="hidden" id="pk" value="" name="pk">
            <div class="shoinf-addt-nr">
                <div class="shoinf-addt-nra">
                    <h1><strong>*</strong>地址信息：</h1>
                    <div class="outer">
                        <select id="province" name="receiverProvince">
                            <option value="请选择">请选择</option>
                        </select>
                        <select id="city" name="receiverCity">
                            <option value="请选择">请选择</option>
                        </select>
                        <select id="town" name="receiverCounty">
                            <option value="请选择">请选择</option>
                        </select>
                    </div>
                </div>
                <div class="shoinf-addt-nra">
                    <h1><strong>*</strong>详细地址：</h1>
                    <p><textarea name="receiverAddress" id="address" placeholder="请输入详细地址信息，如道路、门牌号、小区、楼栋号单元等信息"></textarea></p>
                </div>
                <div class="shoinf-addt-nra">
                    <h1>邮政编码：</h1>
                    <p><input type="text" placeholder="请填写邮编" name="postalCode" id="post" value=""></p>
                </div>
                <div class="shoinf-addt-nra">
                    <h1><strong>*</strong>姓名：</h1>
                    <p><input type="text" placeholder="长度不超过25个字符" name="receiverName" id="name" value=""></p>
                </div>
                <div class="shoinf-addt-nra">
                    <h1><strong>*</strong>手机号码：</h1>
                    <p><input type="text" placeholder="请填写手机号码" name="receiverPhone" id="phone" value=""></p>
                </div>
                <div class="shoinf-addt-nrb">
                    <span><button type="button" onclick="saveAddress()">保存</button></span>
                    <p><button type="button" href="javascript:;" class="claseDialogBtn">关闭</button></p>
                </div>
            </div>
        </form>
    </div>
</div>
<!--==返回头部==-->
<script type="text/javascript" src="/website/js/backtop.js"></script>

<!--==省市区==-->
<script src="http://www.jq22.com/jquery/jquery-1.10.2.js"></script>
<script src="/website/js/address/area.js"></script>
<script src="/website/js/address/select.js"></script>
</body>
<script>
    /*$(function(){
        calculateAll();
    })*/

    function saveAddress(){
        $.ajax({
            url:"/website/personalData/addressAddAndEdit",
            data:$("#addressMessage").serialize(),
            type:"post",
            success:function(resp){
                if(resp.code==200){
                    location.href="/website/shoppingCart/shopping_information?pks="+$("#pks").val();

                }else{
                    layer.msg(resp.message);
                }
            },
            error:function(){
                layer.msg("系统错误");
            }
        })
    }

    //修改地址
    function updateAddress(value){
        var pk = $(value).parent().parent().find("#addressPk").val();
        $.ajax({
            url:'/website/shoppingCart/editAddress',
            data:{'pk':pk},
            type:'get',
            success:function(resp){
                $("#pk").val(resp.data.pk);
                showAddress(resp.data.receiver_province,resp.data.receiver_city,resp.data.receiver_county);
                $("#address").val(resp.data.receiver_address);
                $("#name").val(resp.data.receiver_name);
                $("#phone").val(resp.data.receiver_phone);
            },
            error:function(){
                layer.msg("系统异常")
            }
        })
    }

    function showAddress(receiver_province,receiver_city,receiver_county){
        var cityIndex="";
        var areaIndex="";
        //回显省
        for(var i=0;i<provinceList.length;i++){
            addEle(province,provinceList[i].name);
            if(provinceList[i].name==receiver_province){
                cityIndex=i;
            }
        }
        $("#province").val(receiver_province);
        //回显市
        for (var i = 0; i <provinceList[cityIndex].cityList.length ; i++) {
            addEle(city,provinceList[cityIndex].cityList[i].name);
            if(provinceList[cityIndex].cityList[i].name==receiver_city){
                areaIndex=i;
            }
        }
        $("#city").val(receiver_city);
        //回显区
        for (var i = 0; i <provinceList[cityIndex].cityList[areaIndex].areaList.length; i++) {
            addEle(town,provinceList[cityIndex].cityList[areaIndex].areaList[i]);
        }
        $("#town").val(receiver_county);
    }
    function choseOne(obj){
        $(obj).parent().parent().parent().parent().find("label").removeClass("checkbox_color_c");
        $(obj).parent().addClass("checkbox_color_c");
    }

    //立即付款
    function toPay(){
        var addressPk = $(".checkbox_color_c").parent().parent().find("#addressPk").val();
        var productPks=$("#pks").val();
        if(addressPk==''||addressPk==undefined||addressPk==null){
            layer.msg('请选择地址！！！', {icon: 5});
            return;
        }
        location.href="/website/shoppingCart/shopping_payment?address="+addressPk+"&productPks="+productPks
            +"&c6="+$("#taxNumber").val()+"&c5="+$("#companyName").val()+"&c7="
            +$("#companyAddress").val()+"&c8="+$("#companyPhone").val()+"&c9="+$("#bankName").val()
            +"&c10="+$("#bankNumber").val()+"&orderRemark="+$("#c11").val();
    }

    //开票
    function showBill(){
        $(".bill").css("height","600px");
        $(".billMessage").show();
    }
    //不开票
    function showBillNo() {
        $(".billMessage").hide();
        $(".bill").css("height","30px");
    }
</script>
</html>